<template>
  <div class='upload-img'>
    <el-upload
      class="avatar-uploader"
      :action="uploadUrl"
      :show-file-list="false"
      :on-success="handleAvatarSuccess"
      :before-upload="beforeAvatarUpload">
      <img :src="imageUrl||defaultImg0||defaultImg" class="avatar">
    </el-upload>
  </div>
</template>
<script>
export default {
  props:['defaultImg0',"isreadonly"],
  components: {},
  name: "",
  data() {
    return {
      uploadUrl:picPATH,
      imageUrl:"",
      defaultImg:require('../../assets/imgs/center/default.png')
    };
  },
  methods: {
    /**
     * @name 上传成功
     */
    handleAvatarSuccess(res, file){
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    /**
     * @name 上传拦截
     */
    beforeAvatarUpload(file){
      
      return !this.isreadonly
    }
  },
  created() {}
};
</script>
<style lang="scss" scoped>
.upload-img {
  .avatar{
    width: 150px;
  }
}
</style>